<?php
/**
 * AmazonSKU名称
 * (amazon-model)
 */
namespace App\Models\Amazon;

use Illuminate\Database\Eloquent\Model;
class AmazonSkuName extends Model
{
    protected $connection = 'mysql_amazon';

    protected $table = 'amazon_sku_name';

    protected $guarded  = [];

    public static function addName($sku,$productName)
    {
        if(!$productName)return true;
        $count = self::query()->where('sku',$sku)->count();
        if($count > 0)return true;
        return self::query()->updateOrCreate(['sku' => $sku],['product_name' => $productName]);
    }

    public static function getName($sku)
    {
        return self::query()->where('sku',$sku)->value('product_name');
    }
}
